using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.buff
{
[System.Serializable]
public  class Damage : Buff
 {

    public string expression  = "";
     


    public const int TYPE_ID = 770120448;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(15);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(id);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.BEAN | (3 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_buff_StackType(stackType,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.FLOAT | (4 << Tag.TAG_SHIFT));  os.WriteFloat(duration);  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(affectNum);  
         os.WriteSize(Tag.STRING | (6 << Tag.TAG_SHIFT));  os.WriteString(delay);  
         os.WriteSize(Tag.BOOL | (7 << Tag.TAG_SHIFT));  os.WriteBool(interruptMove);  
         os.WriteSize(Tag.BOOL | (8 << Tag.TAG_SHIFT));  os.WriteBool(interruptCast);  
         os.WriteSize(Tag.BOOL | (9 << Tag.TAG_SHIFT));  os.WriteBool(keepInCity);  
         os.WriteSize(Tag.BOOL | (10 << Tag.TAG_SHIFT));  os.WriteBool(keepWhenDeath);  
         os.WriteSize(Tag.STRING | (11 << Tag.TAG_SHIFT));  os.WriteString(effect);  
         os.WriteSize(Tag.BOOL | (12 << Tag.TAG_SHIFT));  os.WriteBool(effectIvetoPlayer);  
         os.WriteSize(Tag.STRING | (13 << Tag.TAG_SHIFT));  os.WriteString(effectModel);  
         os.WriteSize(Tag.STRING | (14 << Tag.TAG_SHIFT));  os.WriteString(effectAction);  
         os.WriteSize(Tag.STRING | (15 << Tag.TAG_SHIFT));  os.WriteString(expression);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   id = os.ReadInt(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.BEAN | (3 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); stackType = cfg.Extensions.unmarshal_compatible_cfg_buff_StackType(os); os = _oldOs; break; }   
             case (Tag.FLOAT | (4 << Tag.TAG_SHIFT)):   duration = os.ReadFloat(); break;  
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   affectNum = os.ReadInt(); break;  
             case (Tag.STRING | (6 << Tag.TAG_SHIFT)):   delay = os.ReadString(); break;  
             case (Tag.BOOL | (7 << Tag.TAG_SHIFT)):   interruptMove = os.ReadBool(); break;  
             case (Tag.BOOL | (8 << Tag.TAG_SHIFT)):   interruptCast = os.ReadBool(); break;  
             case (Tag.BOOL | (9 << Tag.TAG_SHIFT)):   keepInCity = os.ReadBool(); break;  
             case (Tag.BOOL | (10 << Tag.TAG_SHIFT)):   keepWhenDeath = os.ReadBool(); break;  
             case (Tag.STRING | (11 << Tag.TAG_SHIFT)):   effect = os.ReadString(); break;  
             case (Tag.BOOL | (12 << Tag.TAG_SHIFT)):   effectIvetoPlayer = os.ReadBool(); break;  
             case (Tag.STRING | (13 << Tag.TAG_SHIFT)):   effectModel = os.ReadString(); break;  
             case (Tag.STRING | (14 << Tag.TAG_SHIFT)):   effectAction = os.ReadString(); break;  
             case (Tag.STRING | (15 << Tag.TAG_SHIFT)):   expression = os.ReadString(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Damage");
        ele.WriteStartElement("id"); ele.WriteAttributeString("id", "1"); ele.WriteInt(id); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("stackType"); ele.WriteAttributeString("id", "3"); cfg.Extensions.xml_marshal_cfg_buff_StackType(stackType,ele); ele.WriteEndElement();
         ele.WriteStartElement("duration"); ele.WriteAttributeString("id", "4"); ele.WriteFloat(duration); ele.WriteEndElement();
         ele.WriteStartElement("affectNum"); ele.WriteAttributeString("id", "5"); ele.WriteInt(affectNum); ele.WriteEndElement();
         ele.WriteStartElement("delay"); ele.WriteAttributeString("id", "6"); ele.WriteString2(delay); ele.WriteEndElement();
         ele.WriteStartElement("interruptMove"); ele.WriteAttributeString("id", "7"); ele.WriteBool(interruptMove); ele.WriteEndElement();
         ele.WriteStartElement("interruptCast"); ele.WriteAttributeString("id", "8"); ele.WriteBool(interruptCast); ele.WriteEndElement();
         ele.WriteStartElement("keepInCity"); ele.WriteAttributeString("id", "9"); ele.WriteBool(keepInCity); ele.WriteEndElement();
         ele.WriteStartElement("keepWhenDeath"); ele.WriteAttributeString("id", "10"); ele.WriteBool(keepWhenDeath); ele.WriteEndElement();
         ele.WriteStartElement("effect"); ele.WriteAttributeString("id", "11"); ele.WriteString2(effect); ele.WriteEndElement();
         ele.WriteStartElement("effectIvetoPlayer"); ele.WriteAttributeString("id", "12"); ele.WriteBool(effectIvetoPlayer); ele.WriteEndElement();
         ele.WriteStartElement("effectModel"); ele.WriteAttributeString("id", "13"); ele.WriteString2(effectModel); ele.WriteEndElement();
         ele.WriteStartElement("effectAction"); ele.WriteAttributeString("id", "14"); ele.WriteString2(effectAction); ele.WriteEndElement();
         ele.WriteStartElement("expression"); ele.WriteAttributeString("id", "15"); ele.WriteString2(expression); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  id = ele.ReadInt(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 3:  stackType = cfg.Extensions.xml_unmarshal_cfg_buff_StackType(ele); break; 
                 case 4:  duration = ele.ReadFloat(); break; 
                 case 5:  affectNum = ele.ReadInt(); break; 
                 case 6:  delay = ele.ReadString2(); break; 
                 case 7:  interruptMove = ele.ReadBool(); break; 
                 case 8:  interruptCast = ele.ReadBool(); break; 
                 case 9:  keepInCity = ele.ReadBool(); break; 
                 case 10:  keepWhenDeath = ele.ReadBool(); break; 
                 case 11:  effect = ele.ReadString2(); break; 
                 case 12:  effectIvetoPlayer = ele.ReadBool(); break; 
                 case 13:  effectModel = ele.ReadString2(); break; 
                 case 14:  effectAction = ele.ReadString2(); break; 
                 case 15:  expression = ele.ReadString2(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "id":  id = ele.ReadInt(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "stack_type":  stackType = cfg.Extensions.xml_unmarshal_cfg_buff_StackType(ele); break; 
                 case "duration":  duration = ele.ReadFloat(); break; 
                 case "affect_num":  affectNum = ele.ReadInt(); break; 
                 case "delay":  delay = ele.ReadString2(); break; 
                 case "interrupt_move":  interruptMove = ele.ReadBool(); break; 
                 case "interrupt_cast":  interruptCast = ele.ReadBool(); break; 
                 case "keep_in_city":  keepInCity = ele.ReadBool(); break; 
                 case "keep_when_death":  keepWhenDeath = ele.ReadBool(); break; 
                 case "effect":  effect = ele.ReadString2(); break; 
                 case "effect_iveto_player":  effectIvetoPlayer = ele.ReadBool(); break; 
                 case "effect_model":  effectModel = ele.ReadString2(); break; 
                 case "effect_action":  effectAction = ele.ReadString2(); break; 
                 case "expression":  expression = ele.ReadString2(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
